﻿using System;
using SharpSqlAnalyzer.stmt;

namespace SharpSqlAnalyzer.nodes
{
	// Token: 0x020002E8 RID: 744
	public class TGroupByItem : TParseTreeNode
	{
		// Token: 0x170005D7 RID: 1495
		// (get) Token: 0x06001A2E RID: 6702 RVA: 0x0032D95E File Offset: 0x0032BB5E
		// (set) Token: 0x06001A2F RID: 6703 RVA: 0x0032D966 File Offset: 0x0032BB66
		[Obsolete("use Expr instead")]
		public virtual TExpressionList ExprList
		{
			get
			{
				return this.exprList;
			}
			set
			{
				this.exprList = value;
			}
		}

		// Token: 0x170005D8 RID: 1496
		// (get) Token: 0x06001A30 RID: 6704 RVA: 0x0032D96F File Offset: 0x0032BB6F
		// (set) Token: 0x06001A31 RID: 6705 RVA: 0x0032D977 File Offset: 0x0032BB77
		public virtual TExpression Expr
		{
			get
			{
				return this.expr;
			}
			set
			{
				this.expr = value;
			}
		}

		// Token: 0x170005D9 RID: 1497
		// (get) Token: 0x06001A32 RID: 6706 RVA: 0x0032D980 File Offset: 0x0032BB80
		// (set) Token: 0x06001A33 RID: 6707 RVA: 0x0032D988 File Offset: 0x0032BB88
		public virtual TGroupingSet GroupingSet
		{
			get
			{
				return this.groupingSet;
			}
			set
			{
				this.groupingSet = value;
			}
		}

		// Token: 0x170005DA RID: 1498
		// (get) Token: 0x06001A34 RID: 6708 RVA: 0x0032D991 File Offset: 0x0032BB91
		// (set) Token: 0x06001A35 RID: 6709 RVA: 0x0032D999 File Offset: 0x0032BB99
		public virtual TRollupCube RollupCube
		{
			get
			{
				return this.rollupCube;
			}
			set
			{
				this.rollupCube = value;
			}
		}

		// Token: 0x06001A36 RID: 6710 RVA: 0x0032D9A4 File Offset: 0x0032BBA4
		public override void init(object arg1)
		{
			if (arg1 is TExpression)
			{
				this.expr = (TExpression)arg1;
				return;
			}
			if (arg1 is TRollupCube)
			{
				this.rollupCube = (TRollupCube)arg1;
				return;
			}
			if (arg1 is TGroupingSet)
			{
				this.groupingSet = (TGroupingSet)arg1;
				return;
			}
			if (arg1 is TExpressionList)
			{
				this.exprList = (TExpressionList)arg1;
			}
		}

		// Token: 0x06001A37 RID: 6711 RVA: 0x0032DA04 File Offset: 0x0032BC04
		public override void doParse(TCustomSqlStatement psql, ESqlClause plocation)
		{
			if (this.expr != null)
			{
				if (psql is TSelectSqlStatement && this.expr.ExpressionType == EExpressionType.simple_object_name_t)
				{
					TObjectName objectOperand = this.expr.ObjectOperand;
					TSelectSqlStatement tselectSqlStatement = (TSelectSqlStatement)psql;
					for (int i = 0; i < tselectSqlStatement.ResultColumnList.size(); i++)
					{
						TResultColumn resultColumn = tselectSqlStatement.ResultColumnList.getResultColumn(i);
						if (resultColumn.AliasClause != null && resultColumn.AliasClause.AliasName.ToString().Equals(objectOperand.ToString(), StringComparison.CurrentCultureIgnoreCase))
						{
							objectOperand.ObjectType = 2;
						}
					}
				}
				this.expr.doParse(psql, plocation);
				return;
			}
			if (this.rollupCube != null)
			{
				this.rollupCube.doParse(psql, plocation);
				return;
			}
			if (this.groupingSet != null)
			{
				this.groupingSet.doParse(psql, plocation);
				return;
			}
			if (this.exprList != null)
			{
				this.exprList.doParse(psql, plocation);
			}
		}

		// Token: 0x06001A38 RID: 6712 RVA: 0x0032DAE4 File Offset: 0x0032BCE4
		public override void accept(TParseTreeVisitor v)
		{
			v.preVisit(this);
			v.postVisit(this);
		}

		// Token: 0x06001A39 RID: 6713 RVA: 0x0032DAF4 File Offset: 0x0032BCF4
		public override void acceptChildren(TParseTreeVisitor v)
		{
			v.preVisit(this);
			if (this.expr != null)
			{
				this.expr.acceptChildren(v);
			}
			v.postVisit(this);
		}

		// Token: 0x04001991 RID: 6545
		private TExpression expr;

		// Token: 0x04001992 RID: 6546
		private TRollupCube rollupCube;

		// Token: 0x04001993 RID: 6547
		private TGroupingSet groupingSet;

		// Token: 0x04001994 RID: 6548
		private TExpressionList exprList;
	}
}
